package com.example.facility.controller.admin.receivereturn;


import com.example.facility.common.CommonResult;
import com.example.facility.controller.admin.receivereturn.vo.ReceiveReturnPageReqVO;
import com.example.facility.controller.admin.receivereturn.vo.ReceiveReturnRespVO;
import com.example.facility.service.receivereturn.ReceiveReturnService;
import org.springframework.web.bind.annotation.*;
import org.springframework.validation.annotation.Validated;

import javax.annotation.Resource;

import java.util.List;

import static com.example.facility.common.CommonResult.success;


@RestController
@RequestMapping("/receive/return")
@Validated
@CrossOrigin
public class ReceiveReturnController {

    @Resource
    private ReceiveReturnService returnService;

    /**
     * 删除领用/归还管理
     *
     * @param id
     * @return
     */

    @GetMapping("/delete")
    public CommonResult<Boolean> deleteReturn(@RequestParam("id") Long id) {
        returnService.deleteReturn(id);
        return success(true);
    }

    /**
     * 获得领用归还管理分页 type:1领用 2归还 必填
     *
     * @param pageReqVO
     * @return
     */
    @PostMapping("/list")
    public CommonResult<List<ReceiveReturnRespVO>> selectReturnList(@RequestBody ReceiveReturnPageReqVO pageReqVO) {
        return success(returnService.selectReturnList(pageReqVO));
    }

}